package com.wanli.storemobile.retorfit_manager;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 *
 */

public interface BaseApi {


    //不带参数的通用get请求
    @GET()
    Observable<ResponseBody> executeGet(@Url String url);

    @POST()
    Observable<ResponseBody> executePost(@Url String url);

    @PUT()
    Observable<ResponseBody> executePut(@Url String url);

    @DELETE()
    Observable<ResponseBody> executeDelete(@Url String url);


    //带参数的通用get请求
    @GET()
    Observable<ResponseBody> executeGet(@Url String url, @QueryMap Map<String, Object> maps);

    @POST()
    @FormUrlEncoded
    Observable<ResponseBody> executePost(@Url String url, @FieldMap Map<String, Object> maps);

    @PUT()
    Observable<ResponseBody> executePut(@Url String url, @QueryMap Map<String, Object> maps);

    @DELETE()
    Observable<ResponseBody> executeDelete(@Url String url, @QueryMap Map<String, Object> maps);

    /**
     * 文件上传
     */
    @Multipart
    @POST()
    Observable<ResponseBody> uploadFile(@Url String url, @Part MultipartBody.Part file);

    /**
     * 多文件上传
     */
    @Multipart
    @POST()
    Observable<ResponseBody> uploadMultiFile(@Url String url, @PartMap Map<String, RequestBody> maps);

    /**
     * 多文件上传
     */
    @Multipart
    @POST()
    Observable<ResponseBody> uploadMultiAndFile(@Url String url, @Part() List<MultipartBody.Part> files);


    @Streaming
    @GET
    Call<ResponseBody> download(@Url String url);

}
